///
/// ArmyBodger 3
/// (c)2010 richyp
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArmyBodger.Core {
    /// <summary>
    /// A Collection of Equipment objects
    /// </summary>
    public class EquipmentCollection : List<Equipment> {
        /// <summary>
        /// Indexer to get an Equipment object by name
        /// </summary>
        /// <param name="name">Name of the equipment to retrieve</param>
        /// <returns></returns>
        public Equipment this[string name] {
            get {
                foreach (Equipment equipment in this) {
                    if (equipment.Name == name) {
                        return equipment;
                    }
                }
                return null;
            }
        }
        /// <summary>
        /// Return a collection of Equipment objects in the specified
        /// category
        /// </summary>
        /// <param name="name">Name of the category to retrieve</param>
        /// <returns>A new EquipmentCollection containing only the Equipment
        /// belonging to the specified category</returns>
        public EquipmentCollection GetCategory(string name) {
            EquipmentCollection results = new EquipmentCollection();
            foreach (Equipment equipment in this) {
                if (equipment.Category == name) {
                    results.Add(equipment);
                }
            }
            return results;
        }
    }
}
